<extend name="Public/base" />
<block name="style"> <script
	src="__STATIC__/thinkbox/jquery.thinkbox.js"></script> <script
	type="text/javascript" src="__STATIC__/qtip/jquery.qtip.min.js"></script>
<link rel="stylesheet" type="text/css"
	href="__STATIC__/qtip/jquery.qtip.min.css" media="all">
</block>
<block name="body"> <!-- 标题栏 -->
<div class="main-title">
	<h2>组建试卷 [ {$ib_info['name']} ]</h2>
</div>
<form action="{:U()}" method="post" class="form-horizontal">
	<div class="form-item">
		<label class="item-label">名称<span class="check-tips">（试卷名称，自动填充日期时间）</span></label>
		<div class="controls">
			<input type="text" class="text input-large" name="name"
				value="{$papername}"
				onkeyup="value=value.replace(/(^\s*)|(\s*$)/g,'')">
		</div>
	</div>
	<div class="form-item">
		<label class="item-label">主标题<span class="check-tips">（试卷主标题，包含适用学期、试卷类别、试卷名称等）</span></label>
		<div class="controls">
			<input type="text" class="text input-large" name="mastertitle"
				value="{$mastertitle}"
				onkeyup="value=value.replace(/(^\s*)|(\s*$)/g,'')">
		</div>
	</div>
	<div class="form-item">
		<label class="item-label">副标题<span class="check-tips">（试卷副标题，包含适用专业等）</span></label>
		<div class="controls">
			<input type="text" class="text input-large" name="secondtitle"
				value="{$secondtitle}"
				onkeyup="value=value.replace(/(^\s*)|(\s*$)/g,'')">
		</div>
	</div>

	<div class="form-item">
		<label class="item-label">总分、套数<span class="check-tips">（试卷总分、套数）</span></label>
		<div class="controls">
			<input type="text" class="text input-small" name="score" title="试卷总分"
				value="100" onkeyup="value=value.replace(/[^\d]/g,'')"
				onpaste="return false"> <input type="text"
				class="text input-small" name="sets" title="试卷套数" value="2"
				onkeyup="value=value.replace(/[^\d]/g,'')" onpaste="return false">
		</div>
	</div>
	<div class="form-item">
		<label class="item-label">题型及其章节设置<span class="check-tips">（题型选择、排序、设置类型出题数量及其章节出题数量）</span></label>
		<div class="controls">
			<input type="hidden" name="types" value="{$types}"
				readonly="readonly"> <input type="hidden"
				name="max_types_count" value="{$types_count}" readonly="readonly">
			<input type="hidden" name="types_count" value="{$types_count}"
				readonly="readonly"> <input type="hidden" name="types_score"
				value="{$types_score}" readonly="readonly"> <input
				type="hidden" name="types_info" value="{$types_info}"
				readonly="readonly"><input type="hidden"
				name="chapters_type" value="{$chapters_type}" readonly="readonly">
			<input type="hidden" name="chapters_chapter"
				value="{$chapters_chapter}" readonly="readonly"> <input
				type="hidden" name="max_chapters_count"
				value="{$max_chapters_count}" readonly="readonly"> <input
				type="hidden" name="chapters_count" value="{$chapters_count}"
				readonly="readonly">
			<ul id="sortUl" class="dragsort">
				<volist name="question_types_counts" id="vo">
				<li class="getSort" style="width: 80%; height: auto;" title="拖动排序">
					<div style="margin-left: 10px;margin-right: 10px;">
						<b class="del" title="点击删除">&times;</b> <label class="item-label"
							title="拖动排序">{$vo.questiontype|get_questiontype_name} [
							{$vo.typecount} ]<span class="check-tips">（设置类型题数量、总分、分值分布详情）</span>
						</label> <input type="hidden" name="typeid" value="{$vo['questiontype']}">
						<input type="hidden" name="typecount" value="{$vo['typecount']}">
						<span class="divsion">&nbsp;&nbsp;&nbsp;&nbsp;数量：</span><input
							type="text" class="text input-small" title="类型题数量"
							name="setcount" value="{$vo['typecount']}"
							onkeyup="value=value.replace(/[^\d]/g,'')" onpaste="return false">
						<span class="divsion">&nbsp;&nbsp;&nbsp;&nbsp;总分：</span><input
							type="text" class="text input-small" title="类型题总分"
							name="setscore" value="10"
							onkeyup="value=value.replace(/[^\d]/g,'')" onpaste="return false">
						<span class="divsion">&nbsp;&nbsp;&nbsp;&nbsp;详情：</span><input
							type="text" class="text input-large" title="分值分布详情"
							name="setinfo" value="每小题1分"
							onkeyup="value=value.replace(/(^\s*)|(\s*$)/g,'')"> <label
							class="item-label" title="拖动排序">章节设置<span
							class="check-tips">（设定本题型所含章节出题数量，留空表示随机选择，零表示不选择）</span>
						</label>
						<volist name=":explode('#',$vo['typechaptercounts'])"
							id="typechaptercounts_vo">
						<div style="float: left;margin-bottom: 5px;">
							<volist name=":explode(':',$typechaptercounts_vo)" id="tcc_vo">
							<if condition="$key eq 0"> <input type="hidden"
								name="setchaptertype" value="{$tcc_vo}"> <else /> <if
								condition="$key eq 1"> <input type="hidden"
								name="setchapterchapter" value="{$tcc_vo}"> <span
								class="divsion">&nbsp;&nbsp;&nbsp;&nbsp;{$tcc_vo|get_chapter_name}</span> <else /> <span class="divsion">&nbsp;[ {$tcc_vo} ]：</span>
							<input
								type="hidden" name="setmaxchaptercount" value="{$tcc_vo}">
							<input type="text" class="text input-small" style="width: 60px;"
								title="出题数量，留空表示随机选择，零表示不选择" name="setchaptercount" value=""
								onkeyup="value=value.replace(/[^\d]/g,'')"
								onpaste="return false"></if></if> </volist>
						</div>
						</volist>
					</div>
				</li>
				</volist>
			</ul>
		</div>
	</div>
	<div class="form-item">
		<input type="hidden" name="itembank" value="{$ib_info['id']}" />
		<button class="btn submit-btn ajax-post" id="submit" type="submit"
			target-form="form-horizontal">确 定</button>
		<button class="btn btn-return"
			onclick="javascript:history.back(-1);return false;">返 回</button>
	</div>

</form>
</block>

<block name="script"> <script type="text/javascript"
	src="__STATIC__/jquery.dragsort.js"></script> <script
	type="text/javascript">
	$(function(){
		$("#sortUl").dragsort({
            dragSelector:'li',
            placeHolderTemplate: '<li class="draging-place">&nbsp;</li>',
            dragEnd:function(){
            	updateVal();
            }
        });

		$('#sortUl li div b').click(function(){
        	$(this).parent().parent().remove();
        	updateVal();
        });
		
		$('#sortUl li > div input').change(function(){
        	updateVal();
        });
		
		$('#sortUl li div > div input').change(function(){
        	updateVal();
        });

		// 更新隐藏域的值
        function updateVal() {
        	var typesVal = [];
        	var maxcountVal = [];
        	var countVal = [];
        	var scoreVal = [];
        	var infoVal = [];
        	var chaptertypesVal = [];
        	var chapterchaptersVal = [];
        	var chaptermaxcountsVal = [];
        	var chaptercountsVal = [];
     	
        	$('#sortUl li > div').each(function(){
        		typesVal.push($("input[name='typeid']",this).val());
        		maxcountVal.push($("input[name='typecount']",this).val());
        		countVal.push($("input[name='setcount']",this).val());
        		scoreVal.push($("input[name='setscore']",this).val());
        		infoVal.push($("input[name='setinfo']",this).val());
          	});
        	$('#sortUl li div > div').each(function(){
        	chaptertypesVal.push($("input[name='setchaptertype']",this).val());
    		chapterchaptersVal.push($("input[name='setchapterchapter']",this).val());
    		chaptermaxcountsVal.push($("input[name='setmaxchaptercount']",this).val());
    		chaptercountsVal.push($("input[name='setchaptercount']",this).val());
        	});
        	$("input[name='types']").val(typesVal.join(','));
        	$("input[name='max_types_count']").val(maxcountVal.join(','));
            $("input[name='types_count']").val(countVal.join(','));
            $("input[name='types_score']").val(scoreVal.join(','));
            $("input[name='types_info']").val(infoVal.join('`'));
            $("input[name='chapters_type']").val(chaptertypesVal.join(','));
            $("input[name='chapters_chapter']").val(chapterchaptersVal.join(','));
            $("input[name='max_chapters_count']").val(chaptermaxcountsVal.join(','));
            $("input[name='chapters_count']").val(chaptercountsVal.join(','));
        }
	})
</script> <script type="text/javascript">

	+function($){
		$('.text').each(function(){
	        $(this).qtip({
	            content: {
	                text: $(this).attr('title'),
	                title: ' ',
	            },
	            position: {
	                my: 'top center',
	                at: 'bottom center',
	                target: $(this)
	            },
	            style: {
	                classes: 'qtip-green',
	                tip: {
	                    corner: true,
	                    mimic: false,
	                    width: 5,
	                    height: 5
	                }
	            }
	        });
	    });
		
		$('.del').each(function(){
	        $(this).qtip({
	            content: {
	                text: $(this).attr('title'),
	                title: ' ',
	            },
	            position: {
	                my: 'top center',
	                at: 'bottom center',
	                target: $(this)
	            },
	            style: {
	                classes: 'qtip-green',
	                tip: {
	                    corner: true,
	                    mimic: false,
	                    width: 5,
	                    height: 5
	                }
	            }
	        });
	    });
		
	    //导航高亮
	    $('.side-sub-menu').find('a[href="{:U('index')}"]').closest('li').addClass('current');
	}(jQuery);
	</script> </block>
